package com.smartlazy.sequence.common.single.db.mybatisPlus;

import com.baomidou.mybatisplus.mapper.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;

import java.sql.Timestamp;

/**
 * @author howe
 */
public class PreDateSaveHandler extends MetaObjectHandler {
    @Override
    public void insertFill(MetaObject metaObject) {
        setFieldValByName("createTime", new Timestamp(System.currentTimeMillis()), metaObject);
        setFieldValByName("lastUpdateTime", new Timestamp(System.currentTimeMillis()), metaObject);
        setFieldValByName("version", 0, metaObject);
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        setFieldValByName("lastUpdateTime", new Timestamp(System.currentTimeMillis()), metaObject);
    }
}
